package com.example.mattrigle.Sound;

import com.example.mattrigle.R;

import android.content.Context;
import android.media.MediaPlayer;

public class SoundGame {
	private MediaPlayer mediaplayer;
	private static SoundGame soundGame;

	public static SoundGame getInstance() {
		if (soundGame == null) {
			soundGame = new SoundGame();
		}
		return soundGame;
	}

	public void playSoundMenu(Context context) {
		try {
			stopSound();
			mediaplayer = MediaPlayer.create(context, R.raw.kid);
			mediaplayer.setLooping(true);
			mediaplayer.setVolume(1.0f, 1.0f);
			mediaplayer.start();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void playSoundPlayGame(Context context) {
		try {
			stopSound();
			mediaplayer = MediaPlayer.create(context, R.raw.play);
			mediaplayer.setLooping(true);
			mediaplayer.setVolume(1.0f, 1.0f);
			mediaplayer.start();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void playSoundButton(Context context) {
		try {
			//stopSound();
			MediaPlayer mediaplayer = MediaPlayer.create(context,
					R.raw.multimedia_button_click_029);
			mediaplayer.setVolume(1.0f, 1.0f);
			mediaplayer.start();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void playSoundGameComplete(Context context) {
		try {
			//stopSound();
			MediaPlayer mediaplayer = MediaPlayer.create(context, R.raw.orchestra);
			mediaplayer.setVolume(1.0f, 1.0f);
			mediaplayer.start();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void stopSound() {
		try {
			if (mediaplayer != null) {
				mediaplayer.release();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
